#ifndef _KYLIN_VERIFY_H_
#define _KYLIN_VERIFY_H_

#include <glib.h>

#define LICENSE_GROUP "license"

#define PUBLIC_KEY_MAX_SIZE 1024

typedef struct public_key_info
{
	char content[PUBLIC_KEY_MAX_SIZE];
	unsigned int content_size;
	char* fpr;
	char* keyid;
	unsigned long timestamp;
} public_key_info_t;

/*
 * gpg_verify, verify the signature of a file
 * return NO_ERROR if ok, or error number if not
 */
int gpg_verify(const char * file_to_verify, char** custom_info, unsigned long* custom_info_size);

/*
 * kyinfo_verify, check if kyinfo file can be loaded
 * return 1 if succeed, or 0 if not
 */
int kyinfo_verify(const char* info_file);

/*
 * gpg_encrypt, encrypt with gpg
 * return NO_ERROR if ok, or error number if not
 */
int gpg_encrypt(const char* message_to_encrypt, char** encrypted_message, unsigned long* encrypted_message_size);

/*
 * key_file_get_value, get value from key_file with group and key
 */
char* key_file_get_value(GKeyFile* key_file, char* group, char* key);

/*
 * key_file_set_value, set value to key_file with group and key
 */
void key_file_set_value (GKeyFile* key_file, const char* group, const char* key, const char* value);

/*
 * key_file_to_data, get plain text of a key file
 */
char* key_file_to_data (GKeyFile* key_file, gsize* size);
GKeyFile* key_file_load_from_file(const char* file_name);

/*
 * key_file_save_to_file, save key file content to file
 */
void key_file_save_to_file(GKeyFile* key_file, const char* file_name);

/*
 * license_convert_to_keyfile, convert LICENSE file contents to the format of a key file
 */
GKeyFile* license_convert_to_keyfile(char* license_data, gsize size, char old_delimiter, char new_delimiter);

#endif
